﻿using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Resolve;
using JetBrains.ReSharper.Psi.Xaml.Impl.Resolve;

namespace GammaJul.ReSharper.GammaXaml.Psi.Resolve {
	
	/// <summary>
	/// Symbol filter that filters on the number of parameters.
	/// </summary>
	public class ParameterCountFilter : SimpleSymbolFilterWithErrorType {
		private readonly int _count;
		
		public override bool Accepts(IDeclaredElement declaredElement, ISubstitution substitution) {
			var parametersOwner = declaredElement as IParametersOwner;
			return parametersOwner != null && parametersOwner.Parameters.Count == _count;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="ParameterCountFilter"/> class.
		/// </summary>
		/// <param name="count">The number of parameters.</param>
		public ParameterCountFilter(int count)
			: base(XamlResolveErrorType.PARAMETER_COUNT_MISMATCH) {
			_count = count;
		}
	}

}